<?php
	// Load the QCubed Development Framework
	require('../includes/prepend.inc.php');

	/**
	 * This is a quick-and-dirty draft QForm object to do Create, Edit, and Delete functionality
	 * of the TableUserProfile class.  It uses the code-generated
	 * TableUserProfileMetaControl class, which has meta-methods to help with
	 * easily creating/defining controls to modify the fields of a TableUserProfile columns.
	 *
	 * Any display customizations and presentation-tier logic can be implemented
	 * here by overriding existing or implementing new methods, properties and variables.
	 * 
	 * NOTE: This file is overwritten on any code regenerations.  If you want to make
	 * permanent changes, it is STRONGLY RECOMMENDED to move both table_user_profile_edit.php AND
	 * table_user_profile_edit.tpl.php out of this Form Drafts directory.
	 *
	 * @package My Application
	 * @subpackage Drafts
	 */
	class TableUserProfileEditForm extends QForm {
		// Local instance of the TableUserProfileMetaControl
		protected $mctTableUserProfile;

		// Controls for TableUserProfile's Data Fields
		protected $lblId;
		protected $lstUser;
		protected $txtCompanyUser;
		protected $txtCatchPhrase;
		protected $txtLanguageDescription;
		protected $txtKeywordDescription;
		protected $txtMessage;
		protected $txtLocation;
		protected $txtCustomerCount;
		protected $txtRepeaterCount;
		protected $txtWonProjectCount;
		protected $txtCompletedWonProjectCount;
		protected $txtFailedWonProjectCount;
		protected $txtPostProjectCount;
		protected $txtCompletedPostProjectCount;
		protected $txtFailedPostProjectCount;
		protected $txtBidProjectCount;
		protected $txtBidProjectCountThisMonth;
		protected $txtWonProjectReviewCount;
		protected $txtWonProjectPositiveReviewCount;
		protected $txtWonProjectNeutralReviewCount;
		protected $txtWonProjectNegativeReviewCount;
		protected $txtPostProjectReviewCount;
		protected $txtPostProjectPositiveReviewCount;
		protected $txtPostProjectNeutralReviewCount;
		protected $txtPostProjectNegativeReviewCount;
		protected $txtSuspendCount;
		protected $txtPaypalEmail;
		protected $txtLimitedIp;
		protected $calUpdateDate;
		protected $txtVision;
		protected $txtAreaOfExpertise;
		protected $txtCompletionRatio;
		protected $txtBudgetPaidRatio;
		protected $txtPaginationNumber;
		protected $txtLandingPage;

		// Other ListBoxes (if applicable) via Unique ReverseReferences and ManyToMany References

		// Other Controls
		protected $btnSave;
		protected $btnDelete;
		protected $btnCancel;

		// Create QForm Event Handlers as Needed

//		protected function Form_Exit() {}
//		protected function Form_Load() {}
//		protected function Form_PreRender() {}

		protected function Form_Run() {
			// Security check for ALLOW_REMOTE_ADMIN
			// To allow access REGARDLESS of ALLOW_REMOTE_ADMIN, simply remove the line below
			QApplication::CheckRemoteAdmin();
		}

		protected function Form_Create() {
			// Use the CreateFromPathInfo shortcut (this can also be done manually using the TableUserProfileMetaControl constructor)
			// MAKE SURE we specify "$this" as the MetaControl's (and thus all subsequent controls') parent
			$this->mctTableUserProfile = TableUserProfileMetaControl::CreateFromPathInfo($this);

			// Call MetaControl's methods to create qcontrols based on TableUserProfile's data fields
			$this->lblId = $this->mctTableUserProfile->lblId_Create();
			$this->lstUser = $this->mctTableUserProfile->lstUser_Create();
			$this->txtCompanyUser = $this->mctTableUserProfile->txtCompanyUser_Create();
			$this->txtCatchPhrase = $this->mctTableUserProfile->txtCatchPhrase_Create();
			$this->txtLanguageDescription = $this->mctTableUserProfile->txtLanguageDescription_Create();
			$this->txtKeywordDescription = $this->mctTableUserProfile->txtKeywordDescription_Create();
			$this->txtMessage = $this->mctTableUserProfile->txtMessage_Create();
			$this->txtLocation = $this->mctTableUserProfile->txtLocation_Create();
			$this->txtCustomerCount = $this->mctTableUserProfile->txtCustomerCount_Create();
			$this->txtRepeaterCount = $this->mctTableUserProfile->txtRepeaterCount_Create();
			$this->txtWonProjectCount = $this->mctTableUserProfile->txtWonProjectCount_Create();
			$this->txtCompletedWonProjectCount = $this->mctTableUserProfile->txtCompletedWonProjectCount_Create();
			$this->txtFailedWonProjectCount = $this->mctTableUserProfile->txtFailedWonProjectCount_Create();
			$this->txtPostProjectCount = $this->mctTableUserProfile->txtPostProjectCount_Create();
			$this->txtCompletedPostProjectCount = $this->mctTableUserProfile->txtCompletedPostProjectCount_Create();
			$this->txtFailedPostProjectCount = $this->mctTableUserProfile->txtFailedPostProjectCount_Create();
			$this->txtBidProjectCount = $this->mctTableUserProfile->txtBidProjectCount_Create();
			$this->txtBidProjectCountThisMonth = $this->mctTableUserProfile->txtBidProjectCountThisMonth_Create();
			$this->txtWonProjectReviewCount = $this->mctTableUserProfile->txtWonProjectReviewCount_Create();
			$this->txtWonProjectPositiveReviewCount = $this->mctTableUserProfile->txtWonProjectPositiveReviewCount_Create();
			$this->txtWonProjectNeutralReviewCount = $this->mctTableUserProfile->txtWonProjectNeutralReviewCount_Create();
			$this->txtWonProjectNegativeReviewCount = $this->mctTableUserProfile->txtWonProjectNegativeReviewCount_Create();
			$this->txtPostProjectReviewCount = $this->mctTableUserProfile->txtPostProjectReviewCount_Create();
			$this->txtPostProjectPositiveReviewCount = $this->mctTableUserProfile->txtPostProjectPositiveReviewCount_Create();
			$this->txtPostProjectNeutralReviewCount = $this->mctTableUserProfile->txtPostProjectNeutralReviewCount_Create();
			$this->txtPostProjectNegativeReviewCount = $this->mctTableUserProfile->txtPostProjectNegativeReviewCount_Create();
			$this->txtSuspendCount = $this->mctTableUserProfile->txtSuspendCount_Create();
			$this->txtPaypalEmail = $this->mctTableUserProfile->txtPaypalEmail_Create();
			$this->txtLimitedIp = $this->mctTableUserProfile->txtLimitedIp_Create();
			$this->calUpdateDate = $this->mctTableUserProfile->calUpdateDate_Create();
			$this->txtVision = $this->mctTableUserProfile->txtVision_Create();
			$this->txtAreaOfExpertise = $this->mctTableUserProfile->txtAreaOfExpertise_Create();
			$this->txtCompletionRatio = $this->mctTableUserProfile->txtCompletionRatio_Create();
			$this->txtBudgetPaidRatio = $this->mctTableUserProfile->txtBudgetPaidRatio_Create();
			$this->txtPaginationNumber = $this->mctTableUserProfile->txtPaginationNumber_Create();
			$this->txtLandingPage = $this->mctTableUserProfile->txtLandingPage_Create();

			// Create Buttons and Actions on this Form
			$this->btnSave = new QButton($this);
			$this->btnSave->Text = QApplication::Translate('Save');
			$this->btnSave->AddAction(new QClickEvent(), new QAjaxAction('btnSave_Click'));
			$this->btnSave->CausesValidation = true;

			$this->btnCancel = new QButton($this);
			$this->btnCancel->Text = QApplication::Translate('Cancel');
			$this->btnCancel->AddAction(new QClickEvent(), new QAjaxAction('btnCancel_Click'));

			$this->btnDelete = new QButton($this);
			$this->btnDelete->Text = QApplication::Translate('Delete');
			$this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction(QApplication::Translate('Are you SURE you want to DELETE this') . ' ' . QApplication::Translate('TableUserProfile') . '?'));
			$this->btnDelete->AddAction(new QClickEvent(), new QAjaxAction('btnDelete_Click'));
			$this->btnDelete->Visible = $this->mctTableUserProfile->EditMode;
		}

		/**
		 * This Form_Validate event handler allows you to specify any custom Form Validation rules.
		 * It will also Blink() on all invalid controls, as well as Focus() on the top-most invalid control.
		 */
		protected function Form_Validate() {
			// By default, we report that Custom Validations passed
			$blnToReturn = true;

			// Custom Validation Rules
			// TODO: Be sure to set $blnToReturn to false if any custom validation fails!

			$blnFocused = false;
			foreach ($this->GetErrorControls() as $objControl) {
				// Set Focus to the top-most invalid control
				if (!$blnFocused) {
					$objControl->Focus();
					$blnFocused = true;
				}

				// Blink on ALL invalid controls
				$objControl->Blink();
			}

			return $blnToReturn;
		}

		// Button Event Handlers

		protected function btnSave_Click($strFormId, $strControlId, $strParameter) {
			// Delegate "Save" processing to the TableUserProfileMetaControl
			$this->mctTableUserProfile->SaveTableUserProfile();
			$this->RedirectToListPage();
		}

		protected function btnDelete_Click($strFormId, $strControlId, $strParameter) {
			// Delegate "Delete" processing to the TableUserProfileMetaControl
			$this->mctTableUserProfile->DeleteTableUserProfile();
			$this->RedirectToListPage();
		}

		protected function btnCancel_Click($strFormId, $strControlId, $strParameter) {
			$this->RedirectToListPage();
		}

		// Other Methods

		protected function RedirectToListPage() {
			QApplication::Redirect(__VIRTUAL_DIRECTORY__ . __FORM_DRAFTS__ . '/table_user_profile_list.php');
		}
	}

	// Go ahead and run this form object to render the page and its event handlers, implicitly using
	// table_user_profile_edit.tpl.php as the included HTML template file
	TableUserProfileEditForm::Run('TableUserProfileEditForm');
?>